home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11672 < prev    next >
Encoding:
Text File  |  1996-08-05  |  977 b   |  62 lines

  1. Path: slip129-37-240-94.nc.us.ibm.net!user
  2. From: RobTerrell@vmedia.com (Rob Terrell)
  3. Newsgroups: comp.lang.c++
  4. Subject: Accessing base methods?
  5. Date: Fri, 15 Mar 1996 12:32:28 -0500
  6. Organization: Fringe Multimedia, Inc.
  7. Message-ID: <RobTerrell-1503961232280001@slip129-37-240-94.nc.us.ibm.net>
  8. NNTP-Posting-Host: slip129-37-240-94.nc.us.ibm.net
  9.  
  10.  
  11. I'm just coming back to C++ after a 6-year absence...and I'm trying to
  12. figure out how to access the base methods of a derived class.
  13.  
  14. Take this class:
  15.  
  16.  
  17. class base {
  18.  
  19.    virtual void Move();
  20. }
  21.  
  22. class derived : public base {
  23.  
  24.    void Move();
  25. }
  26.  
  27.  
  28. Okay, so when I'm in the method....
  29.  
  30.  
  31. void derived::Move()
  32. {
  33.  
  34.  // do stuff here
  35.  
  36.  // Now I want to call the base class' Move
  37.  
  38. }
  39.  
  40. How do I do this? I've tried this...
  41.  
  42.  
  43.    (base*)this->Move();
  44.  
  45.  
  46. and crashed spectacularly. I've also tried...
  47.  
  48.  
  49.    base *p;
  50.    p = &derived_obj;
  51.  
  52.    p->Move();
  53.  
  54. With the same explosive results. Can anyone point me in the right direction?
  55.  
  56.  
  57. Thanks,
  58.  
  59.  
  60.  
  61. Rob
  62.